home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PASCSRC.ZIP / BOOLMATH.PAS < prev    next >
Pascal/Delphi Source File  |  1988-01-15  |  1KB  |  35 lines

  1.                                 (* Chapter 3 - Program 6 *)
  2. program Illustrate_What_Boolean_Math_Looks_Like;
  3.  
  4.    (* notice the program name, it can be up to 63 characters long.
  5.       Variables can also be very long as we will see below *)
  6.  
  7. var A,B,C,D : boolean;
  8.     A_Very_Big_Boolean_Name_Can_Be_Used : boolean;
  9.     Junk,Who : integer;
  10.  
  11. begin
  12.    Junk := 4;
  13.    Who := 5;
  14.    A := Junk = Who;    {since Junk is not equal to Who, A is false}
  15.    B := Junk = (Who - 1);  {This is true}
  16.    C := Junk < Who;        {This is true}
  17.    D := Junk > 10;         {This is false}
  18.    A_Very_Big_Boolean_Name_Can_Be_Used := A or B; {Since B is true,
  19.                                                   the result is true}
  20.    Writeln('result A is ',A);
  21.    Writeln('result B is ',B);
  22.    Writeln('result C is ',C);
  23.    Writeln('result D is ',D:12); {This answer will be right justified
  24.                                   in a 12 character field}
  25.    Writeln('result A_Very_Big_Boolean_Name_Can_Be_Used is ',
  26.                    A_Very_Big_Boolean_Name_Can_Be_Used);
  27.  
  28.                       (* Following are a few boolean expressions. *)
  29.    A := B and C and D;
  30.    A := B and C and not D;
  31.    A := B or C or D;
  32.    A := (B and C) or not (C and D);
  33.    A := (Junk = Who - 1) or (Junk = Who);
  34. end.
  35.